<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
<#include "../common/header.ftl">
    <script src="/js/plugins/My97DatePicker/WdatePicker.js"></script>
    <script>
        $(function () {
            $('#pagination').twbsPagination({
                totalPages: ${result.pages},
                startPage: ${result.pageNum},
                visiblePages: ${result.pageSize},
                first: "首页", prev: "上一页",
                next: "下一页",
                last: "末页",
                onPageClick: function (event, page) {
                    $("#currentPage").val(page);
                    $("#searchForm").submit();
                }
            });
            //修改按钮
            $(".editBtn").click(function () {
                $("#editForm")[0].reset();
                var json = $(this).data("json");
                $("#travelCommendId").val(json.id);
                $("#title").val(json.title);
                $("#subTitle").val(json.subTitle);
                $("#schedule").val(json.schedule);
                $("#type").val(json.type);
                //封面
                $("#coverImg").attr('src', json.coverUrl);
                $("#coverUrl").val(json.coverUrl);
                //修改a链接(游记)的地址
                $("#skip").attr('href', "/travelRelease/list.do?travelId=" + json.travelId);
                $("#commendModal").modal('show');
            })
            //保存按钮
            $("#saveBtn").click(function () {
                $("#editForm").ajaxSubmit(function (data) {
                    showMessager(data);
                })
            })
        })
    </script>
</head>
<body>

<div class="container " style="margin-top: 20px">
<#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
        <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">游记推荐管理</h1>
                </div>
            </div>
            <!--高级查询-->
            <form class="form-inline" id="searchForm" action="/travelCommend/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label for="keyword">关键字:</label>
                    <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}"
                           placeholder="请输入标题">
                    <select id="qoType" class="form-control" autocomplete="off" name="type">
                        <option value="-1">全部</option>
                        <option value="1">每周推荐</option>
                        <option value="2">每月推荐</option>
                        <option value="3">攻略推荐</option>
                    </select>
                    <script>
                        $('#type option[value=' + '${qo.type}' + ']').prop('selected', true);
                    </script>
                    <button id="btn_query" class="btn btn-success">查询</button>
                </div>
            </form>
            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>标题</th>
                    <th>封面</th>
                    <th>副标题</th>
                    <th>推荐时间安排</th>
                    <th>推荐类型</th>
                </tr>
                </thead>
            <#list result.list as entity>
                <tr>
                    <td>${entity_index+1}</td>
                    <td>${entity.title}</td>
                    <td><img src="${entity.coverUrl}" width="50px"></td>
                    <td>${entity.subTitle}</td>
                    <td>${(entity.schedule)?string('yyyy-MM-dd HH:mm:ss')}</td>
                    <td>
                        <#if entity.type == 1>
                            每周推荐
                        <#elseif entity.type == 2>
                            每月推荐
                        <#elseif entity.type == 3>
                            攻略推荐
                        </#if>
                    </td>
                    <td>
                        <a href="javascript:;" class="editBtn" data-json='${entity.jsonString}'>修改</a>
                    </td>
                </tr>
            </#list>
            </table>
            <div style="text-align: center;">
                <ul id="pagination" class="pagination"></ul>
            </div>
        </div>
    </div>
</div>
<#include "../travel/editModal.ftl">
</body>
</html>